﻿using System;
using System.Collections.Generic;
using MugenMvvmToolkit.Interfaces;

namespace MugenMvvmToolkitTest.TestInfrastructure
{
    public class TestViewPageMappingProvider : IViewPageMappingProvider
    {
        #region Properties

        public Func<Type, bool, IViewPageMappingItem> FindMappingForView { get; set; }
        public Func<Type, string, bool, IViewPageMappingItem> FindMappingForViewModel { get; set; }

        #endregion

        #region Implementation of IViewPageMappingProvider

        /// <summary>
        ///     Gets a series instances of <see cref="IViewPageMappingItem" />.
        /// </summary>
        public IEnumerable<IViewPageMappingItem> ViewPageMappings { get; set; }

        /// <summary>
        ///     Finds the <see cref="IViewPageMappingItem" /> for the specified type of view.
        /// </summary>
        /// <param name="viewType">The specified type of view.</param>
        /// <param name="throwOnError">
        ///     true to throw an exception if the type cannot be found; false to return null. Specifying
        ///     false also suppresses some other exception conditions, but not all of them.
        /// </param>
        /// <returns>
        ///     An instance of <see cref="IViewPageMappingItem" />.
        /// </returns>
        IViewPageMappingItem IViewPageMappingProvider.FindMappingForView(Type viewType, bool throwOnError)
        {
            return FindMappingForView(viewType, throwOnError);
        }

        /// <summary>
        ///     Finds the <see cref="IViewPageMappingItem" /> for the specified type of view model.
        /// </summary>
        /// <param name="viewModelType">The specified type of view model.</param>
        /// <param name="viewName">The specified name of view, if any.</param>
        /// <param name="throwOnError">
        ///     true to throw an exception if the type cannot be found; false to return null. Specifying
        ///     false also suppresses some other exception conditions, but not all of them.
        /// </param>
        /// <returns>
        ///     An instance of <see cref="IViewPageMappingItem" />.
        /// </returns>
        IViewPageMappingItem IViewPageMappingProvider.FindMappingForViewModel(Type viewModelType, string viewName,
            bool throwOnError)
        {
            return FindMappingForViewModel(viewModelType, viewName, throwOnError);
        }

        #endregion
    }
}